/**
 * GameRuleInfoApi.java
 * com.game.betLottery.api
 * Copyright (c) 2016, 北京聚智未来科技有限公司版权所有.
 */

package com.game.betLottery.api;

import java.util.List;

import com.eova.common.until.StringUtil;
import com.game.betLottery.model.Bet;
import com.game.betLottery.model.GameRuleInfo;
import com.jfinal.core.Controller;

/**
 * TODO(这里用一句话描述这个类的作用)
 * <p>
 * TODO(这里描述这个类补充说明 – 可选)
 *
 * @author gyp
 * @Date 2016年12月15日
 * @Time 下午7:28:48
 */
public class GameRuleInfoApi extends Controller {

	public void getGameRuleInfos() {

		String roomId = getPara("roomId");// 房间的id

		List<GameRuleInfo> gameRuleInfos = GameRuleInfo.dao.getGameRuleInfos();
		GameRuleInfo gameRuleInfo = GameRuleInfo.dao
				.findFirst("select * from game_rule_info where isDelete = 0 order by id");
		setAttr("gameRuleInfos", gameRuleInfos);
		setAttr("gameRuleInfo", gameRuleInfo);

		List<Bet> infos = Bet.dao.getInfos(roomId);
		setAttr("infos", infos);

		setAttr("odds", StringUtil.numToUpper(gameRuleInfo.get("odds")));
		renderJson();
	}

	/**
	 * '
	 * 
	 * 描述:根据规则的id获取规则信息 作者:gyp
	 */
	public void getGameRuleInfo() {

		String rule = getPara("ruleId");
		GameRuleInfo gameRuleInfo = GameRuleInfo.dao.getGameRuleInfo(rule);
		setAttr("gameRuleInfo", gameRuleInfo);
		setAttr("odds", StringUtil.numToUpper(gameRuleInfo.get("odds")));
		renderJson();
	}
}
